package com.txd.mofa.view;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.kongzue.baseframework.util.Preferences;
import com.txd.mofa.R;

import java.lang.reflect.Field;

/**
 * Created by bin on 2018/12/21.
 */

public class ShanchuDialog1 extends Dialog implements View.OnClickListener{

    private String type;
    private SignListener signListener;
    private Context context;
    private TextView tv_quxiao,tv;
    private boolean flag;
    private String type_id;
    private String fenlei;

    private String s;

    private String token;

    public ShanchuDialog1(@NonNull Context context, String type_id, String fenlei, String type, boolean is_myself_post, @NonNull SignListener signListener) {
        super(context,R.style.share_style);
        this.type = type;
        this.signListener = signListener;
        flag = is_myself_post;
        this.context = context;
        this.type_id = type_id;
        this.fenlei = fenlei;
        token = Preferences.getInstance().getString(context, "heima", "token");
    }

    public ShanchuDialog1(@NonNull Context context, @NonNull SignListener signListener) {
        super(context, R.style.share_style);
        this.signListener = signListener;
        this.s = s;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.shanchu_dialog1);

        Window window = this.getWindow();

        //解决 状态栏变色的bug
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setStatusBarColor(Color.TRANSPARENT);
            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
                try {
                    Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView");
                    Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor");
                    field.setAccessible(true);
                    field.setInt(getWindow().getDecorView(), Color.TRANSPARENT);  //去掉高版本蒙层改为透明
                } catch (Exception e) {}
            }
        }

        findViewById(R.id.tv_queding).setOnClickListener(this);


    }


    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.tv_queding:
                this.dismiss();
                break;
        }
    }

    public interface SignListener {
        void shanchu();
    }

}

